<?php

class nahoWikiConfigHandler extends sfYamlConfigHandler
{
  
  public function execute($config_files)
  {
    // retrieve yaml data
    $config = self::parseYamls($config_files);
    
    // get current environment
    $environment = sfConfig::get('sf_environment');
    
    // merge default and environment specific config
    $main_config = isset($config['all']) ? $config['all'] : array();
    $env_config = isset($config[$environment]) ? $config[$environment] : array();
    $config = sfToolKit::arrayDeepMerge($main_config, $env_config);
    
    $code = sprintf("<?php\n" .
                    "// auto-generated by nahoWikiConfigHandler\n" .
                    "// date: %s\n" .
                    "sfConfig::set('app_nahoWikiPlugin_interwiki', %s);",
                    date('Y-m-d H:i:s'), var_export($config, true));
    
    return $code;
  }
  
}
